package pl.prv.polanie.client.dto;

import java.util.Comparator;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * SubjectDTO entity. @author MyEclipse Persistence Tools
 */

public class CSVSubjectDTO extends Object implements IsSerializable, ICSVDTO {

    public static final int SORT_CONST__SUBJECT_NAME_NAME = 0;
    public static final int SORT_CONST__SUBJECT_NAME_SYMBOL = 1;
    public static final int SORT_CONST__SUBJECT_TYPE_NAME = 2;
    public static final int SORT_CONST__SUBJECT_TYPE_INITIAL = 3;
	
    public static final int SORT_CONST__ID = 4;
	
    // Fields    

    private long id;
    private String subjectTypeName;
    private String subjectTypeInitial;
     
     private String subjectNameName;
     private String subjectNameSymbol;
     
     
     

     
     private boolean highlighted;
     

     
     
     

    // Constructors

    /** default constructor */
    public CSVSubjectDTO() {
    }

    
    /** full constructor */
    public CSVSubjectDTO(long id, String subjectTypeName, String subjectTypeInitial, String subjectNameName, String subjectNameSymbol) {
    	this.id = id;
    	this.subjectTypeName = subjectTypeName;
    	this.subjectTypeInitial = subjectTypeInitial;
    	
        this.subjectNameName = subjectNameName;
        this.subjectNameSymbol = subjectNameSymbol;
    }

   
    // Property accessors


    


	//@Override
	public String toString() {
		String result = "" +
		"[ " + CSVSubjectDTO.class + "]" +
		"subjectNameName: " + subjectNameName +
		", subjectNameSymbol: " + subjectNameSymbol +
		", subjectTypeName: " + subjectTypeName + 
		", subjectTypeInitial: " + subjectTypeInitial;
		return result;
	}
	
	
	public String toLabelShort() {
		String result = "" +
			subjectNameSymbol + " " +
			"[" + subjectTypeInitial + "]";
		return result;
	}
	
	public String toLabel() {
		String result = "" +
			subjectNameName + " " +
			"[" + subjectTypeName + "]";
		return result;
	}



	public long getId() {
		return id;
	}


	public void setId(long id) {
		this.id = id;
	}
    
	
	
	
	public String getField(int col) {
		if (col == SORT_CONST__ID) {
			return "" + getId();
		} else if (col == SORT_CONST__SUBJECT_NAME_NAME) {
			return "" + getSubjectNameName();
		} else if (col == SORT_CONST__SUBJECT_NAME_SYMBOL) {
			return "" + getSubjectNameSymbol();
		} else if (col == SORT_CONST__SUBJECT_TYPE_NAME) {
			return "" + getSubjectTypeName();
		} else if (col == SORT_CONST__SUBJECT_TYPE_INITIAL) {
			return "" + getSubjectTypeInitial();
		}
		return "no field";
	}


	public static Comparator getComparator(final int colIndex) {
		Comparator cmp = new Comparator() {
			public int compare(Object o1, Object o2) {

//			    final int BEFORE = -1;
			    final int EQUAL = 0;
//			    final int AFTER = 1;
			    
			    CSVSubjectDTO obj1;
			    CSVSubjectDTO obj2;
			    if (o1 instanceof CSVSubjectDTO && o2 instanceof CSVSubjectDTO) {

					obj1 = (CSVSubjectDTO) o1;
					obj2 = (CSVSubjectDTO) o2;
					
					//this optimization is usually worthwhile, and can
					//always be added
					if ( obj1 == obj2 ) return EQUAL;

					//primitive numbers follow this form
					if (colIndex == SORT_CONST__ID) {
						Long l1 = new Long(obj1.getId());
						Long l2 = new Long(obj2.getId());
						return l1.compareTo(l2);
					} else if (colIndex == SORT_CONST__SUBJECT_NAME_NAME) {
						return obj1.getSubjectNameName().compareTo(obj2.getSubjectNameName());
					} else if (colIndex == SORT_CONST__SUBJECT_NAME_SYMBOL) {
						return obj1.getSubjectNameSymbol().compareTo(obj2.getSubjectNameSymbol());
					} else if (colIndex == SORT_CONST__SUBJECT_TYPE_NAME) {
						return obj1.getSubjectTypeName().compareTo(obj2.getSubjectTypeName());
					} else if (colIndex == SORT_CONST__SUBJECT_TYPE_INITIAL) {
						return obj1.getSubjectTypeInitial().compareTo(obj2.getSubjectTypeInitial());
					}
					
				};
				return EQUAL;
			}
		};

		return cmp;
	}

	
	
	public boolean isHighlighted() {
		return highlighted;
	}


	public void setHighlighted(boolean highlighted) {
		this.highlighted = highlighted;
	}


	public String getSubjectTypeName() {
		return subjectTypeName;
	}


	public void setSubjectTypeName(String subjectTypeName) {
		this.subjectTypeName = subjectTypeName;
	}


	public String getSubjectTypeInitial() {
		return subjectTypeInitial;
	}


	public void setSubjectTypeInitial(String subjectTypeInitial) {
		this.subjectTypeInitial = subjectTypeInitial;
	}


	public String getSubjectNameName() {
		return subjectNameName;
	}


	public void setSubjectNameName(String subjectNameName) {
		this.subjectNameName = subjectNameName;
	}


	public String getSubjectNameSymbol() {
		return subjectNameSymbol;
	}


	public void setSubjectNameSymbol(String subjectNameSymbol) {
		this.subjectNameSymbol = subjectNameSymbol;
	}
    
   
}